import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:todo_app/components/DetectorFocus.dart';
import 'package:todo_app/layout/Header.dart';
import 'package:todo_app/pages/message/components/MessageList.dart';
import 'package:todo_app/pages/message/components/MessagePublishPanel.dart';
import 'package:todo_app/utils/mqtt/MessageEventBus.dart';

class SingleMessagePage extends HookWidget {
  const SingleMessagePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var userId = GoRouterState.of(context).pathParameters["id"];
    return Scaffold(
      appBar: const Header(
        title: "聊天室"
      ),
      body: Column(
        children: [
          Expanded(
            child: DetectorFocus(
              child: MessageList(rid: int.tryParse(userId!)! , category: MessageCategory.single)
            )
          ),
          MessagePublishPanel(
            category: MessageCategory.single,
            receivedId: int.tryParse(userId)!
          )
        ],
      ),
    );
  }
}